package com.atguigu.cart.controller;

import com.atguigu.cart.interceptor.CartInterceptor;
import com.atguigu.cart.vo.UserInfoTo;
import com.atguigu.common.constant.AuthServerConstant;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpSession;

@Controller
public class CartController {

    /**
     *
     * @return
     */

    @PostMapping("addToCart")
    public String addToCart(){
        return "success";
    }

    @GetMapping({"/","/cart.html"})
    public String cartListPage(HttpSession session){
        //1、快速得到用户信息，id，userkey
        UserInfoTo userInfoTo = CartInterceptor.threadLocal.get();
        System.out.println(userInfoTo);
        Object attribute = session.getAttribute(AuthServerConstant.LOGIN_USER);

        return "cartList";
    }
}
